<template>
	<view class="fui-wrap">
		<fui-result v-if="err" type="fail" title="操作失败" :descr="err" :paddingTop="300">
			<fui-button @click="$reLaunch('index/index')" width="400rpx" height="84rpx" text="返回主页" type="success" bold :margin="['48rpx','0','24rpx']"></fui-button>
		</fui-result>
		<block v-else>
			<fui-nav-bar title="系统管理主页" background="#43afe8" color="#fff"></fui-nav-bar>
			<view class="top" style="background:linear-gradient(to bottom, #43afe8, #fff);">
				<fui-avatar width="150" height="150" radius="30" :src="userinfo.avatar"></fui-avatar>
				<fui-text :text="userinfo.nickname" type="black" size="28"></fui-text>
			</view>
			<fui-grid :columns="3">
				<fui-grid-item @click="$navigateTo('admin/parking')">
					<view class="fui-grid__cell">
						<image :src="`${baseUrl}assets/img/miniapp/sparking.png`" class="fui-icon" mode="widthFix"></image>
						<fui-text text="停车场" type="black" size="24"></fui-text>
					</view>
				</fui-grid-item>
			</fui-grid>
		</block>
	</view>
</template>

<script>
	import {methods,baseUrl} from '@/utils/core.js';
	export default {
		data() {
			return {
				err:'',
				userinfo:{},
				baseUrl:baseUrl
			}
		},
		onLoad() {
			this.getInfo();
		},
		methods: {
			...methods,
			getInfo:function(){
				this.$get('admin/index/info').then(res=>{
					this.userinfo=res.user;
				}).catch(err=>{
					this.err=err.msg;
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.fui-wrap{
		background-color: #fff;
		position: fixed;
		left: 0;
		top: 0;
		bottom: 0;
		right: 0;
	}
	.parking{
		padding: 30rpx 0;
		text-align: center;
	}
	.top{
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-around;
		flex-direction: column;
		height: 250rpx;
		padding: 50rpx 0 30rpx 0;
	}
	.fui-grid__cell{
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		text{
			margin-top: 10rpx;
		}
		.fui-icon{
			width: 80rpx;
			height: 80rpx;
		}
	}
</style>